Thread: Enter Char w/o having to press [Return]

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    387

    Question Enter Char w/o having to press [Return]

    Does anyone know how to make it so you can just press a key without havint to press Enter/Return in a windows console app?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    its nonstandard but most compilers offer a getch(),getche(),_getch(),or _getche() functions. All of these will do the job of getting a single char from keyboard but only the onesending in 'e' echo that char to the screen.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User Paro's Avatar
    Join Date
    Feb 2002
    Posts
    160

    hehe

    im pretty sure that what you want is in the awesome FAQ of this site


    Paro

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    i tryed looking on the FAQ and they sed getch() but that doesnt work on MSVC++ =[

  5. #5
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Yes it does, include conio.h.

  6. #6
    Registered User Paro's Avatar
    Join Date
    Feb 2002
    Posts
    160
    no i tried it too on friday with MSVC++ and with <conio.h> it still gave me an error, is there any other way?

  7. #7
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    try sticking getch into your help files search. What comes up....

    oh surprise..... _getch()
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  8. #8
    Unregistered
    Guest
    so its _getch()???? or just getch()

  9. #9
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >no i tried it too on friday with MSVC++ and with <conio.h> it still gave me an error, is there any other way?

    You must be doing something different to me then, as getch() definitely works, what error message do you get?

  10. #10
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    522
    You must be doing something different to me then, as getch() definitely works, what error message do you get?
    I concur, either getch() or _getch() works for me on msvc
    Last edited by C_Coder; 02-17-2002 at 02:15 PM.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  11. #11
    Registered User Paro's Avatar
    Join Date
    Feb 2002
    Posts
    160

    Angry

    this sucks, i cant program til i get back to school next week :'(

    so i cant answer your question to what error, but i think it said "undeclared identifier"

  12. #12
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    522
    The undeclared identifier message means you haven't included the correct header file.
    Unless you commented it out or spelt it wrong.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 08-11-2008, 11:02 PM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  3. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  4. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM